package com.yaorange.certificate.service.impl;

import com.yaorange.certificate.domain.NjtYtjPos;
import com.yaorange.certificate.mapper.NjtYtjPosMapper;
import com.yaorange.certificate.service.NjtYtjPosService;
import com.yaorange.common.utils.DateUtils;
import com.yaorange.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.Collections;
import java.util.Date;
import java.util.List;

/**
 * @author coach tam
 * @email 327395128@qq.com
 * @values 坚持灵活 灵活坚持
 * @since 2025/1/10
 */
@Service
public class NjtYtjPosServiceImpl implements NjtYtjPosService {
    @Autowired
    private NjtYtjPosMapper ytjPosMapper;
    @Override
    @Transactional(readOnly = true, rollbackFor = Exception.class,propagation = Propagation.REQUIRES_NEW,isolation = Isolation.REPEATABLE_READ)
    public List<NjtYtjPos> list(NjtYtjPos njtYtjPos) {
        ytjPosMapper.selectList(njtYtjPos);
        return ytjPosMapper.selectList(njtYtjPos);
    }

    @Override
    public void add(NjtYtjPos njtYtjPos) {
        //设置默认字段数据
        njtYtjPos.setCreateBy(SecurityUtils.getUsername());
        njtYtjPos.setCreateTime(DateUtils.getNowDate());
        ytjPosMapper.insertPos(njtYtjPos);
    }

    @Override
    @Transactional
    public void deleteByIds(Long[] ids) {
        ytjPosMapper.deleteByIds(ids);
    }
}
